package com.ustarlink.live.category;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ustarlink.live.R;

import java.util.ArrayList;

/**
 * Created by cfm on 16-1-20.
 */
public class CategoryAdapter extends ArrayAdapter<Category> {

    public CategoryAdapter(Context context, int resource,ArrayList<Category> objects) {
        super(context, resource, objects);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Category category = getItem(position);
        if (convertView == null){
            LayoutInflater inflater = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = (LinearLayout)inflater.inflate(R.layout.category_list_item, null);
        }
        TextView nameCategory = (TextView)convertView.findViewById(R.id.tv_category);

        nameCategory.setText(category.getCategoryName());

        return convertView;
    }
}
